import { getLngLat } from '@gis/lib/components/AMap/js/AMapUtils.js';

export function isInCircle(target, center, radius, AMap = null) {
  try {
    target = getLngLat(target);
    center = getLngLat(center);
    if (!target || !center) {
      return;
    }
    if (typeof radius !== 'number' || radius <= 0) {
      return false;
    }
    const distance = window.AMap.GeometryUtil.distance(target, center);
    // console.log('distance: ', distance);
    return distance <= radius;
  } catch (error) {
    console.error(error, target, center, radius);
    return false;
  }
}
